package com.farm.bpm.form.impl;

import java.util.List;

import com.farm.bpm.form.Field;
import com.farm.bpm.form.FormParseInter;

public class BooleanFormParse implements FormParseInter {

	@Override
	public Field parse(String fieldType, List<String> parameter, String name, Field field ) {
		if (!"boolean".equals(fieldType)) {
			return null;
		}
		if (field.getValue() != null) {
			if ("TRUE".equals(field.getValue().toUpperCase())) {
				field
						.setFielsHtmlEdit("<span>是</span> <input checked='checked' type='radio' value='true' name='"
								+ field.getName()
								+ "'>&nbsp;&nbsp;否&nbsp;<input type='radio' value='false' name='"
								+ field.getName() + "'>");
			} else {
				field
						.setFielsHtmlEdit("<span>是</span> <input type='radio' value='true' name='"
								+ field.getName()
								+ "'>&nbsp;&nbsp;否&nbsp;<input checked='checked' type='radio' value='false' name='"
								+ field.getName() + "'>");
			}
		} else {
			field
					.setFielsHtmlEdit("<span>是</span> <input type='radio' value='true' name='"
							+ field.getName()
							+ "'>&nbsp;&nbsp;否&nbsp;<input  checked='checked' type='radio' value='false' name='"
							+ field.getName() + "'>");
		}
		return field;
	}

	@Override
	public String getfieldTypeDescribes() {
		return "activiti基本类型:是否";
	}

	@Override
	public String getfieldTypeFormat() {
		return "name='名称' type='boolean'";
	}

	@Override
	public void saveHandle(String fieldType, List<String> parameter,
			String name, Field field) {
		if (!"boolean".equals(fieldType)) {
			return ;
		}
	}

}
